package com.jianying.domain;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Tenant {
	
	public enum Type {
		free,
		pay
	}
	
	private Integer id;
	
	private String name;
	
	private String phone;
	
	private String openid;
	
	private Double capacity;
	
	private Double consumed;

	private String industry;
	
	private String province;
	
	private String city;
	
	private String remark;
	
	private String introduction;
	
	private String logo;
	
	private Integer reviewQuantity;
	
	@JsonFormat(pattern = "yyyy-MM-dd")
	private Date expirationAt;
	
	private Date upgradeAt;
	
	private Date freezeAt;
	
	private Type type;
	
	private Double balance;
	
	private String recommenderName;
	
	private String recommenderPhone;
	
	private Integer addedCapacity;
	
	private String unionid;
	
	private Date createdAt;

	private String nickname;
	
	private String customHome;
	
	private String address;
	
	private String loginName;
	
    private String edition;
	
	private String identifier;
	
//	private TenantConnection tenantConnection;
	
	@JsonProperty
	public Long availableDays() {
		Date now = new Date();
		long days = (expirationAt.getTime() - now.getTime()) / new Long(24 * 60 * 60 * 1000);
		return days;
	}
	
	@JsonProperty
	public String getToken() {
		return unionid;
	}
	
	@JsonProperty
	public boolean isFree() {
		return Type.free.equals(this.type);
	}

	public Integer getId() {
		return id;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getOpenid() {
		return openid;
	}

	public void setOpenid(String openid) {
		this.openid = openid;
	}

	public Double getCapacity() {
		return capacity;
	}

	public void setCapacity(Double capacity) {
		this.capacity = capacity;
	}

	public Double getConsumed() {
		return consumed;
	}

	public void setConsumed(Double consumed) {
		this.consumed = consumed;
	}

	public String getIndustry() {
		return industry;
	}

	public void setIndustry(String industry) {
		this.industry = industry;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getIntroduction() {
		return introduction;
	}

	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}

	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}

	public Integer getReviewQuantity() {
		return reviewQuantity;
	}

	public void setReviewQuantity(Integer reviewQuantity) {
		this.reviewQuantity = reviewQuantity;
	}

	public Date getExpirationAt() {
		return expirationAt;
	}

	public void setExpirationAt(Date expirationAt) {
		this.expirationAt = expirationAt;
	}

	public Date getUpgradeAt() {
		return upgradeAt;
	}

	public void setUpgradeAt(Date upgradeAt) {
		this.upgradeAt = upgradeAt;
	}

	public Date getFreezeAt() {
		return freezeAt;
	}

	public void setFreezeAt(Date freezeAt) {
		this.freezeAt = freezeAt;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public Double getBalance() {
		return balance;
	}

	public void setBalance(Double balance) {
		this.balance = balance;
	}

	public String getRecommenderName() {
		return recommenderName;
	}

	public void setRecommenderName(String recommenderName) {
		this.recommenderName = recommenderName;
	}

	public String getRecommenderPhone() {
		return recommenderPhone;
	}

	public void setRecommenderPhone(String recommenderPhone) {
		this.recommenderPhone = recommenderPhone;
	}

	public Integer getAddedCapacity() {
		return addedCapacity;
	}

	public void setAddedCapacity(Integer addedCapacity) {
		this.addedCapacity = addedCapacity;
	}

	public String getUnionid() {
		return unionid;
	}

	public void setUnionid(String unionid) {
		this.unionid = unionid;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCustomHome() {
		return customHome == null ? "[]" : customHome;
	}

	public void setCustomHome(String customHome) {
		this.customHome = customHome;
	}

	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getEdition() {
		return edition;
	}

	public void setEdition(String edition) {
		this.edition = edition;
	}

	public String getIdentifier() {
		return identifier;
	}

	public void setIdentifier(String identifier) {
		this.identifier = identifier;
	}

//	public TenantConnection getTenantConnection() {
//		return tenantConnection;
//	}
//
//	public void setTenantConnection(TenantConnection tenantConnection) {
//		this.tenantConnection = tenantConnection;
//	}
	
}
